<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 验证回文字符串
    var validPalindrome = function (s) {
      let l = 0, r = s.length - 1;
      while (l < r) {
        if (s[l] != s[r]) {// 1  2      0  2
          return isPli(s, l + 1, r) || isPli(s, l, r - 1);
        }
        l++;
        r--;
      }
      return true;
    };
    function isPli(s, l, r) {
      console.log(s, l, r)//
      while (l < r) {
        if (s[l] != s[r]) {
          return false;
        }
        l++;
        r--;
      }
      return true;
    }
    console.log(validPalindrome('abn'))
  </script>
</body>

</html>